package com.sqk.dxpro.dxsta;

import java.io.IOException;

import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

public class DxStaMain {

	public static void main(String[] args) throws IOException, ClassNotFoundException, IllegalStateException, IllegalArgumentException, InterruptedException {
		Job job1=Job.getInstance();
		job1.setJarByClass(DxStaMain.class);
		job1.setMapperClass(DxStaOneMapper.class);
		job1.setReducerClass(DxStaOneReducer.class);
		job1.setMapOutputKeyClass(Text.class);
		job1.setMapOutputValueClass(IntWritable.class);
		job1.setOutputKeyClass(NullWritable.class);
		job1.setOutputValueClass(Text.class);
		
		FileInputFormat.setInputPaths(job1, new Path("F:\\SparkTask\\DxMatch"));
		FileOutputFormat.setOutputPath(job1, new Path("F:\\SparkTask\\DxStaOne"));
		if(job1.waitForCompletion(true)) {
			Job job2=Job.getInstance();
			job2.setJarByClass(DxStaMain.class);
			job2.setMapperClass(DxStaTwoMapper.class);
			job2.setReducerClass(DxStaTwoReducer.class);
			job2.setMapOutputKeyClass(Text.class);
			job2.setMapOutputValueClass(Text.class);
			job2.setOutputKeyClass(NullWritable.class);
			job2.setOutputValueClass(Text.class);
			FileInputFormat.setInputPaths(job2, new Path("F:\\SparkTask\\DxStaOne"));
			FileOutputFormat.setOutputPath(job2, new Path("F:\\SparkTask\\DxStaTwo"));
			System.exit(job2.waitForCompletion(true) ? 0 : 1);
		}
	}

}
